import numpy as np
F=67e6
w = 2 *np.pi * F
Zo = 50
R = 127
L = 200e-9
XInd = complex(0, w*L)
ZL = R * XInd / (R+XInd)
ZL
Kl = (ZL-Zo)/(ZL+Zo)
Kl
d = 6
B = 2 * np.pi * F/(0.66*3e8)
B
KIn_a=np.exp(complex(0,-2*B*d))
KIn_a
KIn = KIn_a*Kl
KIn
ZIn = Zo * (1+KIn)/(1-KIn)
ZIn
zl = complex(85,32)
z0 = 50
Kl = (zl-z0)/(zl+z0)
Kl
Kl*Kl.conjugate()*250
def V_L(V, Rs, Z0, Zl, n):
Vf = V*Z0/(Z0+Rs)
Kl = (Zl - Z0)/(Zl + Z0)
Ks = (Rs - Z0)/(Rs + Z0)
return (Vf * (1+Kl) * (1 - (Ks*Kl)**n) / (1 - Ks*Kl), Kl, Ks)
v, Kl, Ks = V_L(3.0, 15.0, 88.0, 1000.0, 10000)
v, Kl, Ks
Ks * Kl
(1+Kl)/(1-Ks*Kl)*2.56
1+Kl
def tick(t):
return V_L(3.0, 10.0, 100.0, 9999999999999.0, t)
ts = np.arange(30)
figure(figsize=(10,10))
plot(ts*25, map(tick, ts))
axhline(2.0)
axhline(2.919)
ylim(2.8,3.0)
def tick(r):
return (V_L(3.0, 10.0+r, 100.0, 9999999999999.0, 1)[0], V_L(3.0, 10.0+r, 100.0, 9999999999999.0, 2)[0])
rs = np.arange(1000)
figure(figsize=(10,10))
plot(rs, map(tick, rs), '-')
axhline(2.0)
#xlim(0,20)
#ylim(1.9,2.1)
def tick(r):
return V_L(3.0, 10.0, 100.0, r, 2)[0]
rs = np.arange(1000)
figure(figsize=(10,10))
plot(rs, map(tick, rs), 'o')
axhline(2.0)
#xlim(545,555)
#ylim(1.9,2.1)
%pylab inline
def settle_over(V, Rs, Z0, Zl, V_target):
_, Kl, Ks = V_L(V, Rs, Z0, Zl, 1)
Vf = V * Z0/(Rs+Z0)
t = (V_target-Vf)/Vf
n = (np.log( (t) * (1-Ks*Kl)/(1+Kl)) / np.log(-1*Ks*Kl))
return (n, t, Vf, Ks, Kl)
return (np.log( (V_target)*(1-Ks*Kl)/(Vf)/(1+Kl) - 1 ) / np.log(Ks*Kl), Vf, Ks, Kl)
settle_over(3.0, 10.0, 100.0, 99999999999, 2.9)
16*25
2*np.pi*(0.241*1e-6)*41e6, 1/(2*np.pi*41e6*44e-12)
Zl = complex(0,62) + (complex(0,-88)*154)/(154+complex(0,-88))
Zl
(Zl-50)/(Zl+50)
1.0/Inf
try:
x = 1.0/20
except ZeroDivisionError:
x = Inf
x
20*(log10(sinc(1.0/50)) - log10(sinc(1.0/5)))
xs = np.arange(100)*np.pi
plot(xs, sinc(xs))
def alpf(Fs, N, f):
return np.abs(1.0/N*sin(N*np.pi*f/Fs)/sin(np.pi*f/Fs))
def dB(x):
return 10*np.log(x)
def H_alpf(Fs, N, f):
return dB(alpf(Fs, N, f))
Fs=200
Fs_disp=10000
freqs=np.arange(Fs)+1
figure(figsize=(10,10))
plot(freqs*Fs_disp/Fs, H_alpf(Fs, 8, freqs))
xlim(0,Fs_disp/2)
ylim(-40,0)
Fs=200
Fs_disp=100000
freqs=np.arange(Fs)+1
figure(figsize=(10,10))
plot(freqs*Fs_disp/Fs, dB(alpf(Fs, 7, freqs)*alpf(Fs,5,freqs)))
plot(freqs*Fs_disp/Fs, H_alpf(Fs, 7, freqs))
plot(freqs*Fs_disp/Fs, H_alpf(Fs, 5, freqs))
xlim(0,Fs_disp/2)
ylim(-40,0)